//-------------------------------------------------------------------------------------
//--  scan the fightlist -- this function will find potetial fight if you're already on the fightlist, 
//--  and if you're not, will go to the fightlist so it can do it next pageload
function scanfightlist()
	{
	if (location.href.indexOf(SCRIPT.name+'/fight.php') != -1)
		{
		var fightForms = document.evaluate("//form[@id='"+SCRIPT.appID+"_fight_attack']",document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
		for (var i=0;i<fightForms.snapshotLength;i++)
			{
			var inList = 0;
			fightTable = fightForms.snapshotItem(i).parentNode.parentNode.parentNode;
			opponentId=document.evaluate(".//input[@name='opponent_id']",fightForms.snapshotItem(i),null,9,null).singleNodeValue.value;
			fightInfo=document.evaluate(".//div",fightTable,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
			opponentLevel=parseInt(fightInfo.snapshotItem(1).innerHTML.split('Level ')[1]);
			opponentClan=parseInt(fightInfo.snapshotItem(2).innerHTML.split('Crew Size: ')[1]);
			opponentMaxLevel=parseInt(GM_getValue('fightLevel', '100'));
			opponentMaxClan=parseInt(GM_getValue('fightClanSize', '502'));
			if ((opponentLevel<=opponentMaxLevel) && (opponentClan<=opponentMaxClan))
				{
				if (fightUsers.length > 0)
					{
					for (var j=0;j<fightUsers.length;j++) //scan to see if user is already on the fightlist
						{
						if (fightUsers[j][0] == opponentId)
							{
								inList = 1;
								j = fightUsers.length; //drop out of loop
							}
						}
					}
				if (inList == 0)
					{
					var testArray=new Array(opponentId,opponentLevel,opponentClan);
					fightUsers.push(testArray);
					GM_setValue('fightUsers', uneval(fightUsers));
					}
				}
			}
		}
	else if (GM_getValue('paused')==0)
		{
		window.location = "http://apps.facebook.com/"+SCRIPT.name+"/fight.php";
		flag = 1;
		}	
	}	

